/**
 * 
 */
package com.ssc.portal.www.web;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ssc.manager.trading.dto.BetDto;
import com.ssc.portal.www.service.IInvestBetService;

/**
 * 
 * @author duanhx
 * @version [Ver 1.0; 2012-7-22]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Controller
@RequestMapping("/invest")
public class InvestController {
	
	@Autowired
	private IInvestBetService investBetService;
	/**
	 * 返回JSON数据体
	 * 
	 * @param model
	 * @param user
	 * @return
	 */
	@RequestMapping("/bet")
	public void addBet(@ModelAttribute BetDto bet) {
		bet.setUserid(1);
		bet.setOnlyCode("bobo");
		investBetService.investBet(bet);
	}
	
	@RequestMapping("/test")
	public String test() {
		System.out.println("测试成功");
		return "www/trade";
	}
	
	
	
/*	
	*//**
	 * 返回JSON数据体
	 * 
	 * @param model
	 * @param user
	 * @return
	 *//*
	@RequestMapping("/test1")
	public String userTest1() {


		new Thread(new Runnable() {
			int i=0;
			@Override
			public void run() {
				while (i<=9999) {
					try {
						List <BetDto>list = new ArrayList<BetDto>();
						BetDto betDto = new BetDto();
						betDto.setGameCode("JSSSC");
						betDto.setItemType("DAXIAO");
						betDto.setSumMoney(0.5);
						betDto.setPlayid(String.valueOf(1));
						list.add(betDto);
						clientIntegration.betting(JSON.toJSONString(list));
						System.out.println("fa："+i++);
						Thread.sleep(1);
					} catch (Exception e) {
						e.printStackTrace();
					}
					
				}
				
				
			}
		}).start();
		
		return "demo/user";
	}
	
	

	*//**
	 * 返回JSON数据体
	 * 
	 * @param model
	 * @param user
	 * @return
	 *//*
	@RequestMapping("/test2")
	public String userTest2() {


		new Thread(new Runnable() {
			int i=0;
			@Override
			public void run() {
				while (i<=9999) {
					try {
						List <BetDto>list = new ArrayList<BetDto>();
						BetDto betDto = new BetDto();
						betDto.setGameCode("JSSSC");
						betDto.setItemType("DAXIAO");
						betDto.setSumMoney(0.5);
						betDto.setPlayid(String.valueOf(1));
						list.add(betDto);
						clientIntegration.betting(JSON.toJSONString(list));
						System.out.println("fa："+i++);
						Thread.sleep(1);
					} catch (Exception e) {
						e.printStackTrace();
					}
					
				}
				
				
			}
		}).start();
		
		return "demo/user";
	}
	
	
	
	*//**
	 * 返回JSON数据体
	 * 
	 * @param model
	 * @param user
	 * @return
	 *//*
	@RequestMapping("/test3")
	public String userTest3() {


		new Thread(new Runnable() {
			int i=0;
			@Override
			public void run() {
				while (i<=9999) {
					try {
						List <BetDto>list = new ArrayList<BetDto>();
						BetDto betDto = new BetDto();
						betDto.setGameCode("JSSSC");
						betDto.setItemType("DAXIAO");
						betDto.setSumMoney(0.5);
						betDto.setPlayid(String.valueOf(1));
						list.add(betDto);
						clientIntegration.betting(JSON.toJSONString(list));
						System.out.println("fa："+i++);
						Thread.sleep(1);
					} catch (Exception e) {
						e.printStackTrace();
					}
					
				}
				
				
			}
		}).start();
		
		return "demo/user";
	}
	
	
	*//**
	 * 返回JSON数据体
	 * 
	 * @param model
	 * @param user
	 * @return
	 *//*
	@RequestMapping("/test4")
	public String userTest4() {
		final Cache c = cache;
		c.set("name1", "name1");
		new Thread(new Runnable() {
			int i=0;
			@Override
			public void run() {
				while (i<=9999) {
					try {
						System.out.println(c.get("name1"));
						Thread.sleep(1);
					} catch (Exception e) {
						e.printStackTrace();
					}
					
				}
				
				
			}
		}).start();
		
		return "demo/user";
	}
	
	*//**
	 * 跳转和查询user时调用此方法
	 * URL: http://host:port/SportsMgt/demo
	 * 
	 * @param model
	 * @param user
	 * @return
	 *//*
	@RequestMapping("")
	public String user(Model model, @ModelAttribute UserEntity user) {
		List<UserEntity> list = userService.getUserList(user);
		model.addAttribute("userList", list);
		
		new Thread(new Runnable() {
			int i=0;
			@Override
			public void run() {
				while (i<=9999) {
					try {
						List <BetDto>list = new ArrayList<BetDto>();
						BetDto betDto = new BetDto();
						betDto.setGameCode("JSSSC");
						betDto.setItemType("DAXIAO");
						betDto.setSumMoney(0.5);
						betDto.setPlayid(String.valueOf(1));
						list.add(betDto);
						clientIntegration.betting(JSON.toJSONString(list));
						System.out.println("fa："+i++);
						Thread.sleep(1);
					} catch (Exception e) {
						e.printStackTrace();
					}
					
				}
				
				
			}
		}).start();
		
		return "demo/user";
	}
	
	*//**
	 * 删除user
	 * 
	 * @param id
	 * @param redirectAttributes
	 * @return redirect:表示启用重定向跳转, 避免重复提交
	 *//*
	@RequestMapping(value={"/delete/{id}", "/remove/{id}"})
	public String delete(@PathVariable String id, RedirectAttributes redirectAttributes) {
		userService.deleteUser(new String[]{id});
		redirectAttributes.addFlashAttribute("msg", "删除成功!");
		
		return "redirect:/demo";
	}
	
	
	
	*//**
	 * 跳转新增修改页面时调用此方法
	 * URL: http://host:port/SportsMgt/demo
	 * 
	 * @param model
	 * @param user
	 * @return
	 *//*
	@RequestMapping(value="/input")
	public String input(@RequestParam(value="id", required=false) Integer id, Model model) {
		UserEntity resultUserEntity = new UserEntity();
		if (id != null) {
			resultUserEntity = userService.getUser(new UserEntity(id));
		} 
		model.addAttribute("user", resultUserEntity);
		
		return "demo/user-input";
	}
	
	*//**
	 * 新增或修改user
	 * 
	 * @param user
	 * @param redirectAttributes
	 * @return redirect:表示启用重定向跳转, 避免重复提交
	 *//*
	@RequestMapping("/save")
	public String save(@ModelAttribute("user") UserEntity user, RedirectAttributes redirectAttributes) {
		userService.saveUser(user);
		redirectAttributes.addFlashAttribute("msg", "保存成功!");
		
		return "redirect:/demo";
	}*/
}
